﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SharpHomeEngine
{
 
    public class Tag<T> : Tag where T : struct
    {
        //T MyValue;

        public T Value 
        { 
            get 
            { 
                return (T) MyValue; 
            } 
        }
        public override object ValueObj
        {
            get
            {
                return (Object) MyValue;
            }
        }

        public Tag(DeviceInterface DeviceInterface, Device Device, String Name)
            : base(DeviceInterface, Device, Name)
        {
            MyValue = new T();
        }

        internal void SetValue(T Value)
        {
            MyValue = (T)Value;
            base.SetValue(Value);
        }

        public T CastValue(object Value)
        {
            return (T)Value;
        }

        public Type GetTagType()
        {
            return typeof(T);
        }

        public bool IsSameValueType(Object Value)
        {
            if (Value is T)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
